<template>
<page>
  <head bgcolor="#303030" title="preferential"></head>
  <!-- <div class="curActC">
    <scroller class="shopType" scroll-direction="horizontal">
      <text
        class="typeItem"
        :class="[!activeType?'typeActive':'']"
        @click="activeType='';searchList()"
      >Recommended</text>
      <text
        class="typeItem"
        :class="[activeType==item.id?'typeActive':'']"
        v-for="(item,index) in categroyList"
        :key="index"
        @click="activeType=item.id;searchList()"
      >{{item.name}}</text>
    </scroller>
    <text class="iconfont search" @click="push('root:app/active/activeSearch.js',{type:2})">&#xe62a;</text>
  </div>-->
  <scroller class="shopScro">
    <div class="recontent">
      <GoodItem
        v-for="(item,index) in shopList"
        :key="index"
        :item="item"
        @clickOption="clickOption"
      ></GoodItem>
    </div>
    <text class="loadingTxt" v-if="isLoading">Please wait a minute...</text>
    <empty v-if="shopList.length==0&&!isLoading" tips="No results found" img="root:img/e_seel.png"></empty>
    <text class="loadingbox" v-if="!hasMore&&shopList.length>0">No more</text>
    <div class="mt20"></div>
  </scroller>
  <!-- <div class="maskClack" @click="e=>e.stopPropagation()" v-if="isLoading">
    <floading class="indicator" color="#303030"></floading>
  </div>-->
</page>
</template>

<script>
import { getActiveList, get_banner_list } from "../../mixin/ajax.js";
import GoodItem from "../../component/goodsItem.vue";
import asCore from "../../mixin/core";

export default {
  components: { GoodItem },
  data() {
    return {
      passwd: "",
      page: "1",
      activeTime: "1",
      hasMore: true,
      shopList: [],
      categroyList: [],
      activeType: "",
      userId: "",
      loginType: "email"
    };
  },
  created() {
    asCore.getBsessionid(sessionid => {
      this.userId = sessionid;
    });
    var pref = weex.requireModule("storage");
    pref.getItem("categroy1", event => {
      if (event.result == "success") {
        this.categroyList = JSON.parse(event.data);
      } else {
      }
    });
    this.getList();
  },
  methods: {
    clickOption(id) {
      if (!this.userId) {
        this.push("root:app/login/login.js");
      } else {
        this.push("root:app/order/confirmation.js", { id: id, activity: true });
      }
    },
    searchList() {
      this.page = 1;
      this.getList();
    },
    getList() {
      let that = this;
      this.isLoading = true;
      getActiveList(
        {
          users_id: "",
          keywords: "",
          categoryid: this.activeType,
          start_time: "",
          type: "2",
          page: this.page,
          page_num: "10"
        },
        (res, flag) => {
          this.isLoading = false;
          if (flag) {
            if (res.code == "200") {
              if (this.page > 1) {
                that.shopList = res.data.list;
              } else {
                that.shopList = that.shopList.concat(res.data.list);
              }
              if (res.data.list.length == 0 || res.data.list.length < 10) {
                that.hasMore = false;
              }
            } else {
              that.toast(res.message);
            }
          } else {
            that.shopList = [];
          }
        }
      );
    }
  }
};
</script>

<style scoped>
.iconfont {
  font-family: iconfont;
}
.wrapper {
  background-color: #f5f5f5;
  flex: 1;
}

.curActC {
  flex-direction: row;
  justify-content: space-between;
  width: 750px;
  align-items: center;
  height: 88px;
  padding-left: 32px;
  background-color: #fff;
}
.mt20 {
  margin-top: 20px;
}
.curTit {
  color: #333;
  font-size: 22px;
}
.curCon {
  flex-direction: row;
  align-items: center;
}
.endTime {
  margin-right: 20px;
}
.timeNum {
  width: 30px;
  height: 30px;
  background-color: #bb8732;
  color: #fff;
  border-radius: 5px;
  text-align: center;
  line-height: 30px;
  font-size: 20px;
}

.timesyb {
  color: #bb8732;
  margin: 0 2px;
}

.shopType {
  flex: 1;
}
.search {
  width: 88px;
  text-align: center;
  line-height: 88px;
  font-size: 40px;
  color: #333;
}
.shopType {
  flex-direction: row;
  align-items: center;
}
.typeItem {
  height: 88px;
  line-height: 88px;
  font-size: 30px;
  margin: 0 20px;
  color: #505050;
}
.typeActive {
  border-bottom-color: #ba8833;
  border-bottom-style: solid;
  border-bottom-width: 4px;
}
.shopScro {
  width: 750px;
  background-color: #f2f2f2;
  flex: 1;
}
.shopItem {
  width: 686px;
  height: 268px;
  background-color: rgba(255, 255, 255, 1);
  border-radius: 16px;
  margin-top: 20px;
  padding: 24px;
  flex-direction: row;
}
.shopCon {
  flex: 1;
  height: 220px;
  align-items: flex-start;
  justify-content: space-between;
}
.shopTop {
  align-items: flex-start;
}
.loadingTxt {
  text-align: center;
  padding: 50px 0;
  font-size: 28px;
  color: #999999;
}
.loadingbox {
  align-items: center;
  padding: 20px;
  height: 80px;
  margin-bottom: 20px;
  text-align: center;
  color: #999999;
  font-size: 16px;
}
.shopImg {
  width: 220px;
  height: 220px;
}
.shopTit {
  lines: 1;
  text-overflow: ellipsis;
  font-size: 22px;
  color: #1e1e1e;
}
.titBorder {
  height: 46px;
  border-radius: 23px;
  border-width: 1px;
  border-style: solid;
  border-color: rgba(196, 133, 21, 1);
  line-height: 46px;
  padding: 0 23px;
  font-size: 22px;
  color: #1e1e1e;
  margin-top: 15px;
}
.shopBot {
  width: 418px;
  height: 80px;
  justify-content: space-between;
  flex-direction: row;
  align-items: center;
}
.priceInfo {
  align-items: flex-start;
}
.priceBx {
  flex-direction: row;
  align-items: center;
  height: 45px;
}
.symbol {
  font-size: 20px;
  color: #e52424;
  margin-right: 5px;
}
.cuPrice {
  color: #e52424;
  font-size: 32px;
}
.oldPrice {
  font-size: 22px;
  color: #999999;
  margin-top: 5px;
  text-decoration: line-through;
}
.payBtn {
  height: 44px;
  line-height: 44px;
  background-color: #ec414d;
  color: #fff;
  border-radius: 22px;
  text-align: center;
  padding: 0 20px;
}
.recontent {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 30px;
}
</style>
